package com.clayecloud.module_visitor.adapter;

import android.content.Context;
import android.view.View;

import com.clayecloud.module_visitor.R;
import com.clayecloud.module_visitor.databinding.ActiviryVisitorListItemBinding;
import com.clayecloud.module_visitor.entity.Visitor;

import java.util.List;

public class VisitorListAdapter extends BaseBindingAdapter<Visitor, ActiviryVisitorListItemBinding> {

    private  OnItemClickListener onItemClickListener;

    public VisitorListAdapter(Context context, List list) {
        super(context, list);
    }

    @Override
    protected int getLayoutResId(int viewType) {
        return R.layout.activiry_visitor_list_item;
    }

    @Override
    protected void onBindItem(ActiviryVisitorListItemBinding binding, Visitor item) {
        binding.setModel(item);
        binding.getRoot().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(onItemClickListener != null){
                    onItemClickListener.onItemClick(v,item);
                }
            }
        });
    }

    public interface OnItemClickListener{
        public void onItemClick(View view, Visitor item);
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener){
        this.onItemClickListener = onItemClickListener;
    }
}
